package share.response;

public class CommonReturnType {
    // 0-成功;1-失败
    private Integer status;
    // 若status=0,则data内返回前端需要的json数据
    // 若status=1,则data内使用通用的错误码格式
    private Object data;

    public static CommonReturnType ok(Object result) {
        return create(0, result);
    }

    public static CommonReturnType fail(Integer status, Object result) {
        return create(status, result);
    }

    private static CommonReturnType create(Integer status, Object result) {
        CommonReturnType type = new CommonReturnType();
        type.setStatus(status);
        type.setData(result);
        return type;
    }

    public Integer getStatus() {
        return status;
    }

    public void setStatus(Integer status) {
        this.status = status;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }
}
